{{- define "sourceApp" -}}
(source.labels["{{ .Values.global.appLabelName }}"] | "unknown")
{{- end -}}
{{- define "sourceClusterApp" -}}
conditional((source.labels["istio-cluster"] | "") == "", {{ include "sourceApp" .}}, source.labels["istio-cluster"] + "/" + {{ include "sourceApp" .}})
{{- end -}}
{{- define "destApp" -}}
(destination.labels["{{ .Values.global.appLabelName }}"] | "unknown")
{{- end -}}
{{- define "destClusterApp" -}}
conditional((destination.labels["istio-cluster"] | "") == "", {{ include "destApp" .}}, destination.labels["istio-cluster"] + "/" + {{ include "destApp" .}})
{{- end -}}
{{- define "appLabels" -}}
source_app: {{ include "sourceApp" .}}
source_cluster_app: {{ include "sourceClusterApp" .}}
source_cluster: source.labels["istio-cluster"] | ""
destination_app: {{ include "destApp" .}}
destination_cluster_app: {{ include "destClusterApp" .}}
destination_cluster: destination.labels["istio-cluster"] | ""
source_version: source.labels["{{ .Values.global.versionLabelName }}"] | "unknown"
destination_version: destination.labels["{{ .Values.global.versionLabelName }}"] | "unknown"
traffic_mark: request.headers["{{ .Values.global.trafficMarkHeader }}"] | ""
nsf_duplicate: request.headers["x-nsf-agent"] | "false"
{{- end }}
